package com.vpa.graphics;

import com.vpa.R;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class GraphicsTest extends Activity {

	int bi;
	GraphicsController gfx;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_graphics_test);
		try
		{
			gfx = new GraphicsController((GLView)findViewById(R.id.glview), this);
			gfx.updateGauge((bi = gfx.addAnalogGauge(0, 100, R.drawable.gayge, R.drawable.pinkneedle, "RPM", "Rot/Min")), 100);
			gfx.addDigitalGauge(R.drawable.digital, "penis", "in my mouth");
			
		}
		catch(ThreadedGraphicsException e)
		{
			e.printStackTrace();
			System.exit(0);
		}
		Button b = (Button)(findViewById(R.id.buttontest));
		b.setOnClickListener(new View.OnClickListener()
		{
			public void onClick(View v)
			{
				boolean up = true;
				int iter = 0;
				while(true)
				{
					gfx.updateGauge(bi, iter);
					if(up)
						iter ++;
					else 
						iter --;
					if(iter == 0 || iter == 101)
						up = !up;
					try{Thread.sleep(10);}catch(Exception e){}
				}
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.graphics_test, menu);
		return true;
	}

}
